package com.lemon.common.dto;

import com.lemon.common.exception.ExceptionEnum;
import lombok.Data;

/**
 * 响应实体类
 *
 * @author ymh
 * @date 2019-3-22 17:52
 */
@Data
public class Response<T> {

    // 状态码
    private int status;
    // 信息
    private String message;
    // 数据
    private T data;
    // 时间戳
    private Long timestamp;

    public Response(ExceptionEnum em) {
        this.status = em.getCode();
        this.message = em.getMsg();
        this.timestamp = System.currentTimeMillis();
    }

    public Response(int status, String message) {
        this.status = status;
        this.message = message;
        this.timestamp = System.currentTimeMillis();
    }

    public Response(int status, String message, T data) {
        this(status, message);
        this.data = data;
    }
}
